package edu.uoc.tds.pec4.vista;

import edu.uoc.tds.pec4.gestor.GestorInformes;
import edu.uoc.tds.pec4.model.SS1_CentroDocente;
import edu.uoc.tds.pec4.model.SS1_TipoEvento;
import edu.uoc.tds.pec4.model.SS1_Universidad;
import edu.uoc.tds.pec4.model.SS3_InformeEventosAsistente;
import edu.uoc.tds.pec4.util.ComponentsUtils;
import edu.uoc.tds.pec4.util.ExceptionUtils;
import edu.uoc.tds.pec4.excepciones.FechasIncongruentesException;
import edu.uoc.tds.pec4.util.LanguageUtils;
import java.rmi.RemoteException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;

/**
 * Tecnicas de Desarrollo de Software - (UOC)
 * Clase que modela la pantalla de Informe de Porcentaje de Asistencia
 * @author José Carlos Fernández Luque
 * @version 1.0
 */
public class SS3_PantallaPorcentajeAsistenciaEventos extends javax.swing.JPanel {

    private final DateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    public float numInscritos;
    public float numAsistentes;
    public float porcRow;
    public float porcTotal;
    public GestorInformes objetoRemoto;
    private boolean isInitialCharge = false;

    /**
     *
     * @param objetoRemoto
     */
    public SS3_PantallaPorcentajeAsistenciaEventos(GestorInformes objetoRemoto) {
        this.objetoRemoto = objetoRemoto;
        initComponents();
        formatLanguage();
        intialCharge();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel3 = new javax.swing.JLabel();
        resultPanel = new javax.swing.JPanel();
        resultScroll = new javax.swing.JScrollPane();
        resultTable = new javax.swing.JTable();
        totalResultLabel = new javax.swing.JLabel();
        porcTotalLabel = new javax.swing.JLabel();
        tittleLabel = new javax.swing.JLabel();
        searchPanel = new javax.swing.JPanel();
        fechaHastaField = new javax.swing.JTextField();
        cleanButton = new javax.swing.JButton();
        fechaDesdeField = new javax.swing.JTextField();
        fechaDesdeLabel = new javax.swing.JLabel();
        fechaHastaLabel = new javax.swing.JLabel();
        searchButton = new javax.swing.JButton();
        centerLabel = new javax.swing.JLabel();
        tipoEventoCombo = new javax.swing.JComboBox();
        eventTypeLabel = new javax.swing.JLabel();
        universityLabel = new javax.swing.JLabel();
        porcentajeMayor = new javax.swing.JTextField();
        greaterThanLabel = new javax.swing.JLabel();
        lowerThanLabel = new javax.swing.JLabel();
        porcentajeMenor = new javax.swing.JTextField();
        centroCombo = new javax.swing.JComboBox();
        universidadCombo = new javax.swing.JComboBox();

        resultPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Resultados de la búsqueda"));

        resultTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null}
            },
            new String [] {
                "Universidad del Evento", "Centro Evento", "Evento", "Tipo Evento", "Fecha Inicio", "Plazas"
            }
        ));
        resultScroll.setViewportView(resultTable);

        totalResultLabel.setText("Resultados totales");

        porcTotalLabel.setText("jLabel1");

        javax.swing.GroupLayout resultPanelLayout = new javax.swing.GroupLayout(resultPanel);
        resultPanel.setLayout(resultPanelLayout);
        resultPanelLayout.setHorizontalGroup(
            resultPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(resultPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(resultPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(resultPanelLayout.createSequentialGroup()
                        .addComponent(totalResultLabel)
                        .addGap(73, 73, 73)
                        .addComponent(porcTotalLabel)
                        .addGap(427, 427, 427))
                    .addGroup(resultPanelLayout.createSequentialGroup()
                        .addComponent(resultScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 613, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        resultPanelLayout.setVerticalGroup(
            resultPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, resultPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(resultScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)
                .addGap(11, 11, 11)
                .addGroup(resultPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(totalResultLabel)
                    .addComponent(porcTotalLabel))
                .addContainerGap())
        );

        tittleLabel.setFont(new java.awt.Font("Tahoma", 1, 14));
        tittleLabel.setText("Porcentaje de Asistencia a Eventos");

        searchPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Criterios de búsqueda"));

        fechaHastaField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fechaHastaFieldActionPerformed(evt);
            }
        });

        cleanButton.setText("Limpiar");
        cleanButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cleanButtonActionPerformed(evt);
            }
        });

        fechaDesdeLabel.setText("Fecha desde");

        fechaHastaLabel.setText("Fecha hasta");

        searchButton.setText("Buscar");
        searchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchButtonActionPerformed(evt);
            }
        });

        centerLabel.setText("Centro");

        tipoEventoCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        eventTypeLabel.setText("Tipo Evento");

        universityLabel.setText("Universidad");

        greaterThanLabel.setText("Porcentaje mayor de");

        lowerThanLabel.setText("Porcentaje menor de");

        centroCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        universidadCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        universidadCombo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                universidadComboActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout searchPanelLayout = new javax.swing.GroupLayout(searchPanel);
        searchPanel.setLayout(searchPanelLayout);
        searchPanelLayout.setHorizontalGroup(
            searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(searchPanelLayout.createSequentialGroup()
                .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(searchPanelLayout.createSequentialGroup()
                        .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(universityLabel)
                            .addComponent(centerLabel)
                            .addComponent(eventTypeLabel))
                        .addGap(43, 43, 43)
                        .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(universidadCombo, 0, 244, Short.MAX_VALUE)
                            .addComponent(centroCombo, javax.swing.GroupLayout.Alignment.LEADING, 0, 244, Short.MAX_VALUE)
                            .addComponent(tipoEventoCombo, javax.swing.GroupLayout.Alignment.LEADING, 0, 244, Short.MAX_VALUE)))
                    .addGroup(searchPanelLayout.createSequentialGroup()
                        .addComponent(greaterThanLabel)
                        .addGap(11, 11, 11)
                        .addComponent(porcentajeMayor, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE)
                        .addComponent(lowerThanLabel)
                        .addGap(11, 11, 11)
                        .addComponent(porcentajeMenor, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(searchPanelLayout.createSequentialGroup()
                        .addComponent(cleanButton, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 41, Short.MAX_VALUE)
                        .addComponent(searchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(searchPanelLayout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(fechaHastaLabel)
                            .addComponent(fechaDesdeLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(fechaDesdeField)
                            .addComponent(fechaHastaField, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE))))
                .addContainerGap())
        );
        searchPanelLayout.setVerticalGroup(
            searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(searchPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(universityLabel)
                    .addComponent(fechaDesdeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(universidadCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(fechaHastaLabel))
                .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(searchPanelLayout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(centerLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(centroCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(fechaDesdeLabel)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(eventTypeLabel)
                            .addComponent(tipoEventoCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(greaterThanLabel)
                            .addComponent(porcentajeMayor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lowerThanLabel)
                            .addComponent(porcentajeMenor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(searchPanelLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(fechaHastaField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
                .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cleanButton)
                    .addComponent(searchButton))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(resultPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(searchPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(tittleLabel)
                        .addGap(224, 224, 224))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tittleLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(searchPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(resultPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void cleanButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cleanButtonActionPerformed
        universidadCombo.setSelectedIndex(0);
        centroCombo.setSelectedIndex(0);
        tipoEventoCombo.setSelectedIndex(0);
        fechaDesdeField.setText("");
        fechaHastaField.setText("");
        porcentajeMayor.setText("");
        porcentajeMenor.setText("");
}//GEN-LAST:event_cleanButtonActionPerformed

    private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchButtonActionPerformed
        cercaResult();
}//GEN-LAST:event_searchButtonActionPerformed

    private void universidadComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_universidadComboActionPerformed
        if (!isInitialCharge) {
            cargaComboCentrosPorUniversidad(centroCombo);
        }
    }//GEN-LAST:event_universidadComboActionPerformed

    private void fechaHastaFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fechaHastaFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_fechaHastaFieldActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel centerLabel;
    private javax.swing.JComboBox centroCombo;
    private javax.swing.JButton cleanButton;
    private javax.swing.JLabel eventTypeLabel;
    private javax.swing.JTextField fechaDesdeField;
    private javax.swing.JLabel fechaDesdeLabel;
    private javax.swing.JTextField fechaHastaField;
    private javax.swing.JLabel fechaHastaLabel;
    private javax.swing.JLabel greaterThanLabel;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel lowerThanLabel;
    private javax.swing.JLabel porcTotalLabel;
    private javax.swing.JTextField porcentajeMayor;
    private javax.swing.JTextField porcentajeMenor;
    private javax.swing.JPanel resultPanel;
    private javax.swing.JScrollPane resultScroll;
    private javax.swing.JTable resultTable;
    private javax.swing.JButton searchButton;
    private javax.swing.JPanel searchPanel;
    private javax.swing.JComboBox tipoEventoCombo;
    private javax.swing.JLabel tittleLabel;
    private javax.swing.JLabel totalResultLabel;
    private javax.swing.JComboBox universidadCombo;
    private javax.swing.JLabel universityLabel;
    // End of variables declaration//GEN-END:variables

    private void formatLanguage() {
        fechaDesdeLabel.setText(LanguageUtils.getMessage("SS3.fechaDesde"));
        fechaHastaLabel.setText(LanguageUtils.getMessage("SS3.fechaHasta"));
        centerLabel.setText(LanguageUtils.getMessage("SS3.centro"));
        universityLabel.setText(LanguageUtils.getMessage("SS3.universidad"));
        searchButton.setText(LanguageUtils.getMessage("SS3.buscar"));
        cleanButton.setText(LanguageUtils.getMessage("SS3.limpiar"));
        tittleLabel.setText(LanguageUtils.getMessage("SS3.InformePorcentaje"));
        greaterThanLabel.setText(LanguageUtils.getMessage("SS3.porcMayorDe"));
        lowerThanLabel.setText(LanguageUtils.getMessage("SS3.porcMenorDe"));
        searchPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(LanguageUtils.getMessage("SS3.criterioBusqueda")));
        resultPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(LanguageUtils.getMessage("SS3.resultadoBusqueda")));
        totalResultLabel.setText(LanguageUtils.getMessage("SS3.resultadosTotales"));
        porcTotalLabel.setText("0");
    }

    private void intialCharge() {
        isInitialCharge = true;
        cargaCombo(universidadCombo, "universidades");
        cargaCombo(tipoEventoCombo, "tiposEventos");
        cargaCombo(centroCombo, "centros");
        List listCostByEvent = new ArrayList();
        resultTable = carregaResutTable(resultTable, listCostByEvent);
        isInitialCharge = false;
        porcentajeMayor.setVisible(false);
        greaterThanLabel.setVisible(false);
        lowerThanLabel.setVisible(false);
        porcentajeMenor.setVisible(false);
    }

    private void cargaComboCentrosPorUniversidad(JComboBox centerComb) {
        try {
            List lista = new ArrayList();
            lista = objetoRemoto.dameCentrosUniversidad((SS1_Universidad) universidadCombo.getSelectedItem());
            SS1_CentroDocente nullElement = new SS1_CentroDocente();
            nullElement.setId(-1);
            lista.add(0, nullElement);
            ComponentsUtils.cargaCombo(centerComb, lista);
        } catch (RemoteException ex) {
            ExceptionUtils.visualizarError(LanguageUtils.getMessage("ERR_Remote"));
            Logger.getLogger(SS3_PantallaPorcentajeAsistenciaEventos.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            ExceptionUtils.visualizarError(ExceptionUtils.ERR_Inesperado);
            Logger.getLogger(SS3_PantallaPorcentajeAsistenciaEventos.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void cargaCombo(JComboBox combo, String string) {
        List lista = new ArrayList();
        try {
            if (string.equalsIgnoreCase("universidades")) {
                lista = objetoRemoto.getComboUniversidades();
                SS1_Universidad nullElement = new SS1_Universidad();
                nullElement.setId(-1);
                lista.add(0, nullElement);
            } else if (string.equalsIgnoreCase("tiposEventos")) {
                lista = objetoRemoto.getComboTipoEvento();
                SS1_TipoEvento eventTypeNull = new SS1_TipoEvento();
                eventTypeNull.setId(-1);
                lista.add(0, eventTypeNull);
            } else if (string.equalsIgnoreCase("centros")) {
                lista = objetoRemoto.getComboCentroDocente();
                SS1_CentroDocente nullElement = new SS1_CentroDocente();
                nullElement.setId(-1);
                lista.add(0, nullElement);

            }
        } catch (Exception ex) {
            ExceptionUtils.visualizarError(ExceptionUtils.ERR_Inesperado);
            Logger.getLogger(SS3_PantallaPorcentajeAsistenciaEventos.class.getName()).log(Level.SEVERE, null, ex);
        }
        ComponentsUtils.cargaCombo(combo, lista);
    }

    private JTable carregaResutTable(JTable table, List list) {
        table.removeAll();
        ModelResult model = new ModelResult(list);
        table.setModel(model);
        return table;
    }

    private void cercaResult() {

        List<SS3_InformeEventosAsistente> list = null;
        try {
            if (!fechaDesdeField.getText().equalsIgnoreCase(""))
            {
                Date date = new Date(fechaHastaField.getText());
            }
            if (!fechaHastaField.getText().equalsIgnoreCase(""))
            {
                Date date = new Date(fechaHastaField.getText());
            }
            if (!fechaDesdeField.getText().equalsIgnoreCase("")
                    && !fechaHastaField.getText().equalsIgnoreCase("")
                    && new Date(fechaHastaField.getText()).after(new Date(fechaDesdeField.getText()))) {
                throw new FechasIncongruentesException();
            }

            list = (ArrayList<SS3_InformeEventosAsistente>) objetoRemoto.dameResultPorcentajeAsistencia(
                    (SS1_Universidad) universidadCombo.getSelectedItem(),
                    (SS1_CentroDocente) centroCombo.getSelectedItem(),
                    (SS1_TipoEvento) tipoEventoCombo.getSelectedItem(),
                    fechaHastaField.getText(), fechaDesdeField.getText(),
                    porcentajeMayor.getText(), porcentajeMenor.getText());

            numInscritos = 0;
            numAsistentes = 0;
            porcRow = 0;
            porcTotal = 0;

            for (int i = 0; i < list.size(); i++) {
                porcRow = 0;
                numInscritos = numInscritos + 1;
                if (list.get(i).getAsistencia() == true) {
                    numAsistentes = numAsistentes + 1;
                    porcTotal = porcTotal + 1;
                }
                porcRow = numAsistentes / numInscritos;
                list.get(i).setInscritos((int) numInscritos);
                list.get(i).setAsistentes((int) numAsistentes);
                list.get(i).setPorcentaje((int) porcRow * 100);
            }
            if (porcTotal != 0) {
                porcTotal = porcTotal / list.size();
                porcTotalLabel.setText(porcTotal * 100 + " %");
            } else {
                porcTotalLabel.setText("0" + " %");
            }
        } catch (FechasIncongruentesException ex) {
            ExceptionUtils.visualizarInformacion(LanguageUtils.getMessage("SS3.error.formato.fecha.incongruentes"));
            Logger.getLogger(SS3_PantallaPorcentajeAsistenciaEventos.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ParseException ex) {
            ExceptionUtils.visualizarInformacion(LanguageUtils.getMessage("SS3.error.formato.fecha.incorrecta"));
            Logger.getLogger(SS3_PantallaPorcentajeAsistenciaEventos.class.getName()).log(Level.SEVERE, null, ex);
        } catch (RemoteException ex) {
            ExceptionUtils.visualizarError(LanguageUtils.getMessage("ERR_Remote"));
            Logger.getLogger(SS3_PantallaPorcentajeAsistenciaEventos.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            ExceptionUtils.visualizarInformacion(LanguageUtils.getMessage("SS3.error.formato.incorrecto"));
            Logger.getLogger(SS3_PantallaPorcentajeAsistenciaEventos.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            ExceptionUtils.visualizarError(ExceptionUtils.ERR_Inesperado);
            Logger.getLogger(SS3_PantallaPorcentajeAsistenciaEventos.class.getName()).log(Level.SEVERE, null, ex);
        }

        resultTable = carregaResutTable(resultTable, list);

    }

    class ModelResult extends AbstractTableModel {

        private static final long serialVersionUID = 1L;
        protected Vector<String> cabecera = new Vector<String>();
        protected Vector<Vector> eventosAsistente = new Vector<Vector>();

        public ModelResult(List<SS3_InformeEventosAsistente> lissS3_InformeEventosAsistente) {
            setCapcelera();
            setResulTabla(lissS3_InformeEventosAsistente);
        }

        private void setCapcelera() {
            cabecera.add(LanguageUtils.getMessage("SS3.universidad"));
            cabecera.add(LanguageUtils.getMessage("SS3.centro"));
            cabecera.add(LanguageUtils.getMessage("SS3.evento"));
            cabecera.add(LanguageUtils.getMessage("SS3.tipoEvento"));
            cabecera.add(LanguageUtils.getMessage("SS3.fechaInicio"));
            cabecera.add(LanguageUtils.getMessage("SS3.plazas"));
//            cabecera.add(LanguageUtils.getMessage("SS3.inscritos"));
//            cabecera.add(LanguageUtils.getMessage("SS3.asistentes"));
//            cabecera.add(LanguageUtils.getMessage("SS3.porcAsistencia"));
        }

        private void setResulTabla(List<SS3_InformeEventosAsistente> listSS3_InformeEventosAsistente) {
            Vector<String> universityColumn = new Vector<String>();
            Vector<String> centerColumn = new Vector<String>();
            Vector<String> eventColumn = new Vector<String>();
            Vector<String> eventTypeColumn = new Vector<String>();
            Vector<String> initDateColumn = new Vector<String>();
            Vector<String> placesColumn = new Vector<String>();
//            Vector<String> registerColumn = new Vector<String>();
//            Vector<String> assistantsColumn = new Vector<String>();
//            Vector<String> percentColumn = new Vector<String>();

            for (Iterator<SS3_InformeEventosAsistente> it = listSS3_InformeEventosAsistente.iterator(); it.hasNext();) {
                SS3_InformeEventosAsistente sS3_InformeEventosAsistente = it.next();
                universityColumn.add(sS3_InformeEventosAsistente.getUniversidad());
                centerColumn.add(sS3_InformeEventosAsistente.getCentro());
                eventColumn.add(sS3_InformeEventosAsistente.getEvento());
                eventTypeColumn.add(sS3_InformeEventosAsistente.getTipoEvento());
                initDateColumn.add(sdf.format(new java.util.Date()));
                placesColumn.add(sS3_InformeEventosAsistente.getPlazas() + "");
//                registerColumn.add(sS3_InformeEventosAsistente.getInscritos() + "");
//                assistantsColumn.add(sS3_InformeEventosAsistente.getAsistentes() + "");
//                percentColumn.add(sS3_InformeEventosAsistente.getPorcentaje() + "");
            }
            eventosAsistente.add(universityColumn);
            eventosAsistente.add(centerColumn);
            eventosAsistente.add(eventColumn);
            eventosAsistente.add(eventTypeColumn);
            eventosAsistente.add(initDateColumn);
            eventosAsistente.add(placesColumn);
//            eventosAsistente.add(registerColumn);
//            eventosAsistente.add(assistantsColumn);
//            eventosAsistente.add(percentColumn);
        }

        public int getRowCount() {
            return (((Vector) eventosAsistente.get(0)).size());
        }

        public int getColumnCount() {
            return (eventosAsistente.size());
        }

        @Override
        public String getColumnName(int col) {
            return ((String) cabecera.get(col));
        }

        public boolean getScrollableTrackViewportHeight() {
            return (true);
        }

        public boolean getScrollableTrackViewportWidth() {
            return (true);
        }

        public Object getValueAt(int fila, int col) {
            return (((Vector) eventosAsistente.get(col)).get(fila));
        }

        @Override
        public boolean isCellEditable(int fila, int columna) {
            return (false);
        }
    }
}
